(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

U11(tt, V2) → U12(isNat(activate(V2)))
U12(tt) → tt
U21(tt) → tt
U31(tt, N) → activate(N)
U41(tt, M, N) → U42(isNat(activate(N)), activate(M), activate(N))
U42(tt, M, N) → s(plus(activate(N), activate(M)))
isNat(n__0) → tt
isNat(n__plus(V1, V2)) → U11(isNat(activate(V1)), activate(V2))
isNat(n__s(V1)) → U21(isNat(activate(V1)))
plus(N, 0) → U31(isNat(N), N)
plus(N, s(M)) → U41(isNat(M), M, N)
0n__0
plus(X1, X2) → n__plus(X1, X2)
s(X) → n__s(X)
activate(n__0) → 0
activate(n__plus(X1, X2)) → plus(X1, X2)
activate(n__s(X)) → s(X)
activate(X) → X

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

U11(tt, V2) → U12(isNat(activate(V2))) [1]
U12(tt) → tt [1]
U21(tt) → tt [1]
U31(tt, N) → activate(N) [1]
U41(tt, M, N) → U42(isNat(activate(N)), activate(M), activate(N)) [1]
U42(tt, M, N) → s(plus(activate(N), activate(M))) [1]
isNat(n__0) → tt [1]
isNat(n__plus(V1, V2)) → U11(isNat(activate(V1)), activate(V2)) [1]
isNat(n__s(V1)) → U21(isNat(activate(V1))) [1]
plus(N, 0) → U31(isNat(N), N) [1]
plus(N, s(M)) → U41(isNat(M), M, N) [1]
0n__0 [1]
plus(X1, X2) → n__plus(X1, X2) [1]
s(X) → n__s(X) [1]
activate(n__0) → 0 [1]
activate(n__plus(X1, X2)) → plus(X1, X2) [1]
activate(n__s(X)) → s(X) [1]
activate(X) → X [1]

Rewrite Strategy: INNERMOST

(3) CpxWeightedTrsRenamingProof (BOTH BOUNDS(ID, ID) transformation)

Renamed defined symbols to avoid conflicts with arithmetic symbols:

0 => 0'

(4) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

U11(tt, V2) → U12(isNat(activate(V2))) [1]
U12(tt) → tt [1]
U21(tt) → tt [1]
U31(tt, N) → activate(N) [1]
U41(tt, M, N) → U42(isNat(activate(N)), activate(M), activate(N)) [1]
U42(tt, M, N) → s(plus(activate(N), activate(M))) [1]
isNat(n__0) → tt [1]
isNat(n__plus(V1, V2)) → U11(isNat(activate(V1)), activate(V2)) [1]
isNat(n__s(V1)) → U21(isNat(activate(V1))) [1]
plus(N, 0') → U31(isNat(N), N) [1]
plus(N, s(M)) → U41(isNat(M), M, N) [1]
0'n__0 [1]
plus(X1, X2) → n__plus(X1, X2) [1]
s(X) → n__s(X) [1]
activate(n__0) → 0' [1]
activate(n__plus(X1, X2)) → plus(X1, X2) [1]
activate(n__s(X)) → s(X) [1]
activate(X) → X [1]

Rewrite Strategy: INNERMOST

(5) InnermostUnusableRulesProof (BOTH BOUNDS(ID, ID) transformation)

Removed the following rules with non-basic left-hand side, as they cannot be used in innermost rewriting:

plus(N, 0') → U31(isNat(N), N) [1]
plus(N, s(M)) → U41(isNat(M), M, N) [1]

Due to the following rules that have to be used instead:

0'n__0 [1]
s(X) → n__s(X) [1]

(6) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

U11(tt, V2) → U12(isNat(activate(V2))) [1]
U12(tt) → tt [1]
U21(tt) → tt [1]
U31(tt, N) → activate(N) [1]
U41(tt, M, N) → U42(isNat(activate(N)), activate(M), activate(N)) [1]
U42(tt, M, N) → s(plus(activate(N), activate(M))) [1]
isNat(n__0) → tt [1]
isNat(n__plus(V1, V2)) → U11(isNat(activate(V1)), activate(V2)) [1]
isNat(n__s(V1)) → U21(isNat(activate(V1))) [1]
0'n__0 [1]
plus(X1, X2) → n__plus(X1, X2) [1]
s(X) → n__s(X) [1]
activate(n__0) → 0' [1]
activate(n__plus(X1, X2)) → plus(X1, X2) [1]
activate(n__s(X)) → s(X) [1]
activate(X) → X [1]

Rewrite Strategy: INNERMOST

(7) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(8) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

U11(tt, V2) → U12(isNat(activate(V2))) [1]
U12(tt) → tt [1]
U21(tt) → tt [1]
U31(tt, N) → activate(N) [1]
U41(tt, M, N) → U42(isNat(activate(N)), activate(M), activate(N)) [1]
U42(tt, M, N) → s(plus(activate(N), activate(M))) [1]
isNat(n__0) → tt [1]
isNat(n__plus(V1, V2)) → U11(isNat(activate(V1)), activate(V2)) [1]
isNat(n__s(V1)) → U21(isNat(activate(V1))) [1]
0'n__0 [1]
plus(X1, X2) → n__plus(X1, X2) [1]
s(X) → n__s(X) [1]
activate(n__0) → 0' [1]
activate(n__plus(X1, X2)) → plus(X1, X2) [1]
activate(n__s(X)) → s(X) [1]
activate(X) → X [1]

The TRS has the following type information:
U11 :: tt → n__0:n__plus:n__s → tt
tt :: tt
U12 :: tt → tt
isNat :: n__0:n__plus:n__s → tt
activate :: n__0:n__plus:n__s → n__0:n__plus:n__s
U21 :: tt → tt
U31 :: tt → n__0:n__plus:n__s → n__0:n__plus:n__s
U41 :: tt → n__0:n__plus:n__s → n__0:n__plus:n__s → n__0:n__plus:n__s
U42 :: tt → n__0:n__plus:n__s → n__0:n__plus:n__s → n__0:n__plus:n__s
s :: n__0:n__plus:n__s → n__0:n__plus:n__s
plus :: n__0:n__plus:n__s → n__0:n__plus:n__s → n__0:n__plus:n__s
n__0 :: n__0:n__plus:n__s
n__plus :: n__0:n__plus:n__s → n__0:n__plus:n__s → n__0:n__plus:n__s
n__s :: n__0:n__plus:n__s → n__0:n__plus:n__s
0' :: n__0:n__plus:n__s

Rewrite Strategy: INNERMOST

(9) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:
none

And the following fresh constants: none

(10) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

U11(tt, V2) → U12(isNat(activate(V2))) [1]
U12(tt) → tt [1]
U21(tt) → tt [1]
U31(tt, N) → activate(N) [1]
U41(tt, M, N) → U42(isNat(activate(N)), activate(M), activate(N)) [1]
U42(tt, M, N) → s(plus(activate(N), activate(M))) [1]
isNat(n__0) → tt [1]
isNat(n__plus(V1, V2)) → U11(isNat(activate(V1)), activate(V2)) [1]
isNat(n__s(V1)) → U21(isNat(activate(V1))) [1]
0'n__0 [1]
plus(X1, X2) → n__plus(X1, X2) [1]
s(X) → n__s(X) [1]
activate(n__0) → 0' [1]
activate(n__plus(X1, X2)) → plus(X1, X2) [1]
activate(n__s(X)) → s(X) [1]
activate(X) → X [1]

The TRS has the following type information:
U11 :: tt → n__0:n__plus:n__s → tt
tt :: tt
U12 :: tt → tt
isNat :: n__0:n__plus:n__s → tt
activate :: n__0:n__plus:n__s → n__0:n__plus:n__s
U21 :: tt → tt
U31 :: tt → n__0:n__plus:n__s → n__0:n__plus:n__s
U41 :: tt → n__0:n__plus:n__s → n__0:n__plus:n__s → n__0:n__plus:n__s
U42 :: tt → n__0:n__plus:n__s → n__0:n__plus:n__s → n__0:n__plus:n__s
s :: n__0:n__plus:n__s → n__0:n__plus:n__s
plus :: n__0:n__plus:n__s → n__0:n__plus:n__s → n__0:n__plus:n__s
n__0 :: n__0:n__plus:n__s
n__plus :: n__0:n__plus:n__s → n__0:n__plus:n__s → n__0:n__plus:n__s
n__s :: n__0:n__plus:n__s → n__0:n__plus:n__s
0' :: n__0:n__plus:n__s

Rewrite Strategy: INNERMOST

(11) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

tt => 0
n__0 => 0

(12) Obligation:

Complexity RNTS consisting of the following rules:

0' -{ 1 }→ 0 :|:
U11(z, z') -{ 1 }→ U12(isNat(activate(V2))) :|: z' = V2, V2 >= 0, z = 0
U12(z) -{ 1 }→ 0 :|: z = 0
U21(z) -{ 1 }→ 0 :|: z = 0
U31(z, z') -{ 1 }→ activate(N) :|: z' = N, z = 0, N >= 0
U41(z, z', z'') -{ 1 }→ U42(isNat(activate(N)), activate(M), activate(N)) :|: z' = M, z = 0, z'' = N, M >= 0, N >= 0
U42(z, z', z'') -{ 1 }→ s(plus(activate(N), activate(M))) :|: z' = M, z = 0, z'' = N, M >= 0, N >= 0
activate(z) -{ 1 }→ X :|: X >= 0, z = X
activate(z) -{ 1 }→ s(X) :|: z = 1 + X, X >= 0
activate(z) -{ 1 }→ plus(X1, X2) :|: X1 >= 0, X2 >= 0, z = 1 + X1 + X2
activate(z) -{ 1 }→ 0' :|: z = 0
isNat(z) -{ 1 }→ U21(isNat(activate(V1))) :|: z = 1 + V1, V1 >= 0
isNat(z) -{ 1 }→ U11(isNat(activate(V1)), activate(V2)) :|: V1 >= 0, V2 >= 0, z = 1 + V1 + V2
isNat(z) -{ 1 }→ 0 :|: z = 0
plus(z, z') -{ 1 }→ 1 + X1 + X2 :|: X1 >= 0, X2 >= 0, z = X1, z' = X2
s(z) -{ 1 }→ 1 + X :|: X >= 0, z = X

Only complete derivations are relevant for the runtime complexity.

(13) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V3, V4),0,[fun(V, V3, Out)],[V >= 0,V3 >= 0]).
eq(start(V, V3, V4),0,[fun1(V, Out)],[V >= 0]).
eq(start(V, V3, V4),0,[fun2(V, Out)],[V >= 0]).
eq(start(V, V3, V4),0,[fun3(V, V3, Out)],[V >= 0,V3 >= 0]).
eq(start(V, V3, V4),0,[fun4(V, V3, V4, Out)],[V >= 0,V3 >= 0,V4 >= 0]).
eq(start(V, V3, V4),0,[fun5(V, V3, V4, Out)],[V >= 0,V3 >= 0,V4 >= 0]).
eq(start(V, V3, V4),0,[isNat(V, Out)],[V >= 0]).
eq(start(V, V3, V4),0,[fun6(Out)],[]).
eq(start(V, V3, V4),0,[plus(V, V3, Out)],[V >= 0,V3 >= 0]).
eq(start(V, V3, V4),0,[s(V, Out)],[V >= 0]).
eq(start(V, V3, V4),0,[activate(V, Out)],[V >= 0]).
eq(fun(V, V3, Out),1,[activate(V21, Ret00),isNat(Ret00, Ret0),fun1(Ret0, Ret)],[Out = Ret,V3 = V21,V21 >= 0,V = 0]).
eq(fun1(V, Out),1,[],[Out = 0,V = 0]).
eq(fun2(V, Out),1,[],[Out = 0,V = 0]).
eq(fun3(V, V3, Out),1,[activate(N1, Ret1)],[Out = Ret1,V3 = N1,V = 0,N1 >= 0]).
eq(fun4(V, V3, V4, Out),1,[activate(N2, Ret001),isNat(Ret001, Ret01),activate(M1, Ret11),activate(N2, Ret2),fun5(Ret01, Ret11, Ret2, Ret3)],[Out = Ret3,V3 = M1,V = 0,V4 = N2,M1 >= 0,N2 >= 0]).
eq(fun5(V, V3, V4, Out),1,[activate(N3, Ret002),activate(M2, Ret011),plus(Ret002, Ret011, Ret02),s(Ret02, Ret4)],[Out = Ret4,V3 = M2,V = 0,V4 = N3,M2 >= 0,N3 >= 0]).
eq(isNat(V, Out),1,[],[Out = 0,V = 0]).
eq(isNat(V, Out),1,[activate(V11, Ret003),isNat(Ret003, Ret03),activate(V22, Ret12),fun(Ret03, Ret12, Ret5)],[Out = Ret5,V11 >= 0,V22 >= 0,V = 1 + V11 + V22]).
eq(isNat(V, Out),1,[activate(V12, Ret004),isNat(Ret004, Ret04),fun2(Ret04, Ret6)],[Out = Ret6,V = 1 + V12,V12 >= 0]).
eq(fun6(Out),1,[],[Out = 0]).
eq(plus(V, V3, Out),1,[],[Out = 1 + X11 + X21,X11 >= 0,X21 >= 0,V = X11,V3 = X21]).
eq(s(V, Out),1,[],[Out = 1 + X3,X3 >= 0,V = X3]).
eq(activate(V, Out),1,[fun6(Ret7)],[Out = Ret7,V = 0]).
eq(activate(V, Out),1,[plus(X12, X22, Ret8)],[Out = Ret8,X12 >= 0,X22 >= 0,V = 1 + X12 + X22]).
eq(activate(V, Out),1,[s(X4, Ret9)],[Out = Ret9,V = 1 + X4,X4 >= 0]).
eq(activate(V, Out),1,[],[Out = X5,X5 >= 0,V = X5]).
input_output_vars(fun(V,V3,Out),[V,V3],[Out]).
input_output_vars(fun1(V,Out),[V],[Out]).
input_output_vars(fun2(V,Out),[V],[Out]).
input_output_vars(fun3(V,V3,Out),[V,V3],[Out]).
input_output_vars(fun4(V,V3,V4,Out),[V,V3,V4],[Out]).
input_output_vars(fun5(V,V3,V4,Out),[V,V3,V4],[Out]).
input_output_vars(isNat(V,Out),[V],[Out]).
input_output_vars(fun6(Out),[],[Out]).
input_output_vars(plus(V,V3,Out),[V,V3],[Out]).
input_output_vars(s(V,Out),[V],[Out]).
input_output_vars(activate(V,Out),[V],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. non_recursive : [fun6/1]
1. non_recursive : [plus/3]
2. non_recursive : [s/2]
3. non_recursive : [activate/2]
4. non_recursive : [fun1/2]
5. non_recursive : [fun2/2]
6. recursive [non_tail,multiple] : [fun/3,isNat/2]
7. non_recursive : [fun3/3]
8. non_recursive : [fun5/4]
9. non_recursive : [fun4/4]
10. non_recursive : [start/3]

#### Obtained direct recursion through partial evaluation
0. SCC is completely evaluated into other SCCs
1. SCC is completely evaluated into other SCCs
2. SCC is completely evaluated into other SCCs
3. SCC is partially evaluated into activate/2
4. SCC is completely evaluated into other SCCs
5. SCC is completely evaluated into other SCCs
6. SCC is partially evaluated into isNat/2
7. SCC is completely evaluated into other SCCs
8. SCC is partially evaluated into fun5/4
9. SCC is partially evaluated into fun4/4
10. SCC is partially evaluated into start/3

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations activate/2
* CE 9 is refined into CE [17]
* CE 10 is refined into CE [18]
* CE 11 is refined into CE [19]


### Cost equations --> "Loop" of activate/2
* CEs [17,18,19] --> Loop 8

### Ranking functions of CR activate(V,Out)

#### Partial ranking functions of CR activate(V,Out)


### Specialization of cost equations isNat/2
* CE 14 is refined into CE [20]
* CE 13 is refined into CE [21]
* CE 12 is refined into CE [22]


### Cost equations --> "Loop" of isNat/2
* CEs [22] --> Loop 9
* CEs [21] --> Loop 10
* CEs [20] --> Loop 11

### Ranking functions of CR isNat(V,Out)
* RF of phase [9,11]: [V]

#### Partial ranking functions of CR isNat(V,Out)
* Partial RF of phase [9,11]:
- RF of loop [9:1,9:2,11:1]:
V


### Specialization of cost equations fun5/4
* CE 16 is refined into CE [23]


### Cost equations --> "Loop" of fun5/4
* CEs [23] --> Loop 12

### Ranking functions of CR fun5(V,V3,V4,Out)

#### Partial ranking functions of CR fun5(V,V3,V4,Out)


### Specialization of cost equations fun4/4
* CE 15 is refined into CE [24,25]


### Cost equations --> "Loop" of fun4/4
* CEs [25] --> Loop 13
* CEs [24] --> Loop 14

### Ranking functions of CR fun4(V,V3,V4,Out)

#### Partial ranking functions of CR fun4(V,V3,V4,Out)


### Specialization of cost equations start/3
* CE 2 is refined into CE [26,27]
* CE 3 is refined into CE [28]
* CE 4 is refined into CE [29]
* CE 5 is refined into CE [30,31]
* CE 6 is refined into CE [32]
* CE 7 is refined into CE [33,34]
* CE 8 is refined into CE [35]


### Cost equations --> "Loop" of start/3
* CEs [26,27,28,29,30,31,32,33,34,35] --> Loop 15

### Ranking functions of CR start(V,V3,V4)

#### Partial ranking functions of CR start(V,V3,V4)


Computing Bounds
=====================================

#### Cost of chains of activate(V,Out):
* Chain [8]: 2
with precondition: [V=Out,V>=0]


#### Cost of chains of isNat(V,Out):
* Chain [10]: 1
with precondition: [V=0,Out=0]

* Chain [multiple([9,11],[[10]])]: 13*it(9)+1*it([10])+0
Such that:it([10]) =< V+1
aux(1) =< V
it(9) =< aux(1)

with precondition: [Out=0,V>=1]


#### Cost of chains of fun5(V,V3,V4,Out):
* Chain [12]: 7
with precondition: [V=0,V3+V4+2=Out,V3>=0,V4>=0]


#### Cost of chains of fun4(V,V3,V4,Out):
* Chain [14]: 15
with precondition: [V=0,V4=0,V3+2=Out,V3>=0]

* Chain [13]: 1*s(1)+13*s(3)+14
Such that:s(2) =< V4
s(1) =< V4+1
s(3) =< s(2)

with precondition: [V=0,V3+V4+2=Out,V3>=0,V4>=1]


#### Cost of chains of start(V,V3,V4):
* Chain [15]: 1*s(4)+13*s(6)+1*s(8)+13*s(9)+1*s(10)+13*s(12)+15
Such that:s(11) =< V
s(10) =< V+1
s(5) =< V3
s(4) =< V3+1
s(7) =< V4
s(8) =< V4+1
s(12) =< s(11)
s(6) =< s(5)
s(9) =< s(7)

with precondition: []


Closed-form bounds of start(V,V3,V4):
-------------------------------------
* Chain [15] with precondition: []
- Upper bound: nat(V)*13+15+nat(V3)*13+nat(V4)*13+nat(V+1)+nat(V3+1)+nat(V4+1)
- Complexity: n

### Maximum cost of start(V,V3,V4): nat(V)*13+15+nat(V3)*13+nat(V4)*13+nat(V+1)+nat(V3+1)+nat(V4+1)
Asymptotic class: n
* Total analysis performed in 168 ms.

(14) BOUNDS(1, n^1)